﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;

namespace BusinessObjects
{
    public class Person
    {
        public Guid PersonId { get; set; }
        public Guid RoleId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Position { get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
        public string PasswordSalt { get; set; }
        public string Email { get; set; }

        public List<Measure> Measures { get; set; }
        public Role Role { get; set; }
        public List<Project> Projects { get; set; }

        /// <summary>
        /// Возвращает список всех сотрудников.
        /// </summary>
        /// <returns></returns>
        public List<Person> Retrieve()
        {
            try
            {
                RiskManagementContext сontext = new RiskManagementContext();
                var query = from c in сontext.Persons.Include("Measures").Include("Projects").Include("Role") select c;
                return query.ToList();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error in Person Retrieve - " + ex.Message, ex);
            }
        }
    }
}
